<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryRef" :inline="true" label-width="auto" v-show="showSearch">
            <el-form-item label="订单号" prop="appointmentCode">
                <el-input
                    v-model="queryParams.appointmentCode"
                    placeholder="请输入订单号"
                    clearable
                    @keyup.enter="handleQuery"
                />
            </el-form-item>
            <el-form-item label="预约状态" prop="appointmentStatus">
               <el-select v-model="queryParams.appointmentStatus" placeholder="预约状态" clearable style="width: 200px">
                  <el-option
                     v-for="dict in dict.type.reservat_status"
                     :key="dict.value"
                     :label="dict.label"
                     :value="dict.value"
                  />
               </el-select>
            </el-form-item>

            <el-form-item >
                <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
                <el-button icon="Refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
            <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" :data="list">
            <el-table-column label="订单号" align="center" prop="appointmentCode"/>
            <el-table-column label="预约状态" align="center" prop="appointmentStatus">
                <template slot-scope="{row}">
                    <dict-tag :options="dict.type.reservat_status" :value="row.appointmentStatus" />
                </template>
            </el-table-column>
            <el-table-column label="预约开始时间" align="center" prop="startTime" :show-overflow-tooltip="true"/>
            <el-table-column label="预约结束时间" align="center" prop="endTime"/>
            <el-table-column label="最大预约时长" align="center" prop="maxBookTime">
                <template slot-scope="{row}">
                    {{row.maxBookTime == -1 ? '无限制' : row.maxBookTime}}
                </template>
            </el-table-column>
            <el-table-column label="预约是否需要审核" align="center" prop="isApprovalRequired">
                <template slot-scope="{row}">
                    <dict-tag :options="dict.type.is_yes_no" :value="row.isApprovalRequired" />
                </template>
            </el-table-column>
            <el-table-column label="提交时间" align="center" prop="submitTime"/>
            <el-table-column label="审核时间" align="center" prop="auditTime"/>
            <el-table-column label="取消时间" align="center" prop="cancelTime"/>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
    </div>
</template>

<script >
import {personalAppointmentList,getPersonalAppointment} from "@/api/everyonePile/reservatList";

export default {
  name: 'ReservatList',
  dicts: ['reservat_status','is_yes_no'],
  components: {  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      queryParams: {// 查询参数
        pageNum: 1,
        pageSize: 10,
        dateRange:[],
      },
      // 总条数
      total: 0,
      list:[],//页面数据
    };
  },
  mounted(){
    this.getList()
  },
  methods: {
    getList() {
      this.loading = true;
      let queryParams = {...this.queryParams}
      personalAppointmentList(queryParams).then(response => {
        this.list = response.rows || [];
        this.total = response.total || 0;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {// 查询参数
        pageNum: 1,
        pageSize: 10,
      }
      this.resetForm("queryRef");
      this.handleQuery();
    },
  }
}
</script>
